﻿using System;
using System.Collections.Generic;
using System.Text;
using XiaoGang.Soft.XGWMS.MODEL;
using XiaoGang.Soft.XGWMS.COM;
using XiaoGang.Soft.XGWMS.DAL_SQL;

namespace XiaoGang.Soft.XGWMS.BLL
{
    public class BLL_M014_MerberBuy
    {
        DAL_SQL.DAL_M014_MerberBuy dal = new DAL_M014_MerberBuy ();
        private readonly XiaoGang.Soft.XGWMS.BLL.BLL_ComProcess bll_ComProcess = new BLL_ComProcess ();

        public ReturnValue Add ( MOD_M014_MerberBuy model )
        {
            //MOD_M011_GET_ID modGetID = new MOD_M011_GET_ID ();
            //modGetID.UPDATER_ID = model.UPDATER_ID;
            //modGetID.TERMINAL_CD = model.TERMINAL_CD;
            //modGetID.GETID_DIV = "08";
            //modGetID.FISCAL_YEAR = System.DateTime.Now.Year.ToString ("####");
            //ReturnValue returnValue = bll_ComProcess.GetSlipID (modGetID);
            //if (!returnValue.ErrorFlag)
            //{
            //    return returnValue;
            //}
            //model.ID = returnValue.ResultDataSet.Tables[0].Rows[0]["SLIPID"].ToString ().Trim ();

            string UniqueNo = string.Empty;
            if (!DAL_ComProcess.GetUniqueNo(model.UPDATER_ID
                , model.TERMINAL_CD
                , "08"
                , System.DateTime.Now.Year.ToString("####")
                , out UniqueNo))
            {
                return new ReturnValue(false,"E11003");
            }
            model.ID= UniqueNo;
            return dal.Add (model);
        }

        /// <summary>
        /// 更新一条数据
        /// </summary>
        public ReturnValue Update ( MOD_M014_MerberBuy model )
        {
            return dal.Update (model);
        }

        /// <summary>
        /// 删除一条数据
        /// </summary>
        public ReturnValue Delete ( string ID )
        {
            return dal.Delete (ID);
        }

        public ReturnValue GetList(string MemberID)
        {
            return dal.GetList(MemberID);
        }
    }
}
